/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.component.open.api.facade.result;

import info.peigen.hotpot.common.core.result.SingleResult;
import lombok.AccessLevel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import lombok.experimental.FieldDefaults;

/**
 * <b>(OpenSingleResult)</b>
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2021/8/12
 */
@SuppressWarnings({"rawtypes", "unchecked"})
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE)
@Accessors(chain = true)
public class OpenSingleResult<T> extends SingleResult<T> {

    public static OpenSingleResult convert(SingleResult result) {
        OpenSingleResult openSingleResult = new OpenSingleResult();
        openSingleResult.setInfo(result.getInfo())
                .setStatus(result.getStatus()).setCode(result.getCode()).setDetail(result.getDetail())
                .setOperatorId(result.getOperatorId()).setCost(result.getCost()).setFee(result.isFee());

        return openSingleResult;
    }
}